﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Hkwl.WorldExpo.Merchant.Common;
using Hkwl.WorldExpo.Merchant.Model;
using Hkwl.WorldExpo.Merchant.Service;

namespace Hkwl.WorldExpo.Merchant.Web
{
    public partial class ShowLoginInfo : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["MerchantId"] != null)
                {
                    NxMerchant nxMerchant = ServiceLocator.IMerchantService.GetNxMerchant(int.Parse(Session["MerchantId"].ToString()));
                    this.lbLoginName.Text = nxMerchant.LoginName;
                }
                else
                {
                    JavaScript.WriteJs("jAlert('" + (String)GetGlobalResourceObject("Default","PLEASE_LOGIN_AGAIN") + "','" + (String)GetGlobalResourceObject("Default", "NOTE") + "','Login.aspx')", this.Page);
                }
            }
        }

        protected void btn_Logout_Click(object sender, ImageClickEventArgs e)
        {
            Session.Clear();
            Session.Abandon();
            JavaScript.WriteJs("jAlert('" + (String)GetGlobalResourceObject("Default", "YOU_ARE_LOGOUTED") + "','" + (String)GetGlobalResourceObject("Default", "NOTE") + "','Login.aspx')", this.Page);
        }
    }
}